package com.zswlib.netease.webapp.controller;

import com.zswlib.netease.webapp.dao.BlogDAO;
import com.zswlib.netease.webapp.mapper.BlogMapper;
import com.zswlib.netease.webapp.po.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;
@RestController
@RequestMapping("blog")
public class BlogController extends BaseExceptionHandler{
    @Autowired
    private BlogDAO blogDAO;

    @RequestMapping(value = "list", method = {RequestMethod.GET})
    public List<Blog> list(){
        return blogDAO.listBlog();
    }

    @RequestMapping(method = {RequestMethod.POST, RequestMethod.GET})
    /** * @author GZzhongshaowei(zhongshaowei@corp.netease.com) 2018/2/5 */
    public boolean saveBlog(Blog blog) throws Exception {
        try{
            blogDAO.saveBlog(blog);
        } catch (Exception e){
            throw e;
        }
        return true;
    }
}
